# Huawei Technologies Co.,Ltd.

set(NEWOBJDYNRANGE_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/newobjdynrange.txt)
set(NEWOBJDYNRANGE_JS ${CMAKE_CURRENT_SOURCE_DIR}/newobjdynrange.js)
set(NEWOBJDYNRANGE_BIN ${CMAKE_CURRENT_BINARY_DIR}/newobjdynrange.abc)
set(NEWOBJDYNRANGE_PA ${CMAKE_CURRENT_BINARY_DIR}/newobjdynrange.pa)
set(NEWOBJDYNRANGE_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${NEWOBJDYNRANGE_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${NEWOBJDYNRANGE_OUTPUT}
    COMMENT "running javascript newobjdynrange testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${NEWOBJDYNRANGE_JS} --dump-assembly --output ${NEWOBJDYNRANGE_BIN} > ${NEWOBJDYNRANGE_PA}
    COMMAND rm -f ${NEWOBJDYNRANGE_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${NEWOBJDYNRANGE_OUTPUT}
    COMMAND bash ${NEWOBJDYNRANGE_VERIFY} ${NEWOBJDYNRANGE_OUTPUT}
)
add_custom_target(newobjdynrange
    DEPENDS ${NEWOBJDYNRANGE_OUTPUT} ${NEWOBJDYNRANGE_VERIFY}
)
add_dependencies(newobjdynrange es2panda ark)
add_dependencies(ecmascript_common_tests newobjdynrange)
